var APP = {title: 'BM Sofort'};

$EL = function(element_name) {
  var nodeName = element_name.replace(/([\[\]\|])/g, '\\$1');
  return jQuery(nodeName);
}

var itd_UtilAlert = {
  debug: function(msg) {
    alert(msg);
  },

  alert: function(msg) {
    if ((typeof dhtmlx.message) != "undefined") 
      dhtmlx.alert({title:APP.title, text:msg});
    else 
      this.alert(msg);
  },

  info: function(msg) {
    if ((typeof dhtmlx.message) != "undefined") 
      dhtmlx.alert({title:APP.title, text:"<img src='/images/icons/bell_error.png'>" + msg });
    else 
      this.alert("INFO: " + msg);
  },

  error: function(msg) {
    if ((typeof dhtmlx.message) != "undefined") 
      dhtmlx.alert({type:"alert-error", title:APP.title, text: msg });
    else 
      this.alert("FEHLER:" + msg);
  },
  
  confirm: function(msg, btnLabels, fn_cb) {
    if ((typeof dhtmlx.message) == "undefined") 
      return confirm(msg);
    else {
      var btn = btnLabels||["Ja", "Nein"];
      dhtmlx.confirm({
        title: APP.title,
        ok: btn[0], cancel: btn[1],
        text: msg,
        callback:function(resp){ 
          if (resp == true) fn_cb(); 
        }
      });
    }
  }
  
};

(function($){
  $.array_unique = function(arr){
    return $.grep(arr, function(v, k) {
      return $.inArray(v ,arr) === k;
    });
  };
  
  // popup window on help images
  $.fn.popuphelp = function () {
  	return this.each(function(){
  		var rel = $(this).attr('rel');
  		$(this).mouseover( function(){ TagToTip(rel); });
  		$(this).mouseout(UnTip);
  	});
  };

  // popups
  $.fn.popuplayer = function () {
  	return this.each(function() {
  		$(this).click(function() {
  			var box = '#'+$(this).attr('href');
  			jQuery(box).center().fadeIn(300);
  			jQuery('#mask_popup').fadeIn(300);
  			return false;
  		});
  	});
  };
  
})(jQuery);

